package com.briup.day25.Set;

import java.util.Comparator;
import java.util.Set;
import java.util.TreeSet;

public class TreeSetTest1 {
	
	public static void main(String[] args) {
		
		Comparator c = new Comparator() {
			public int compare(Object o1, Object o2) {

				int i1 = ((String)o1).length();
				int i2 = ((String)o2).length();
				
				//按照长度升序
				if (i1 > i2) {
					return 1;      //降序-1
				}else {
					return -1;
				}
			}
		};
		
		Set set = new TreeSet(c);
		
		set.add("HashSet");
		set.add("ArrayList");
		set.add("TreeMap");
		set.add("HashMap");
		set.add("TreeSet");
		set.add("LinkedList");
		
		
		System.out.println(set.size());
		
		set.forEach(System.out::println);
	}
		
}


